<template>
    <div>
      <!-- <temperature></temperature> -->
       <!-- 打印 -->
        <button @click="print">打印</button>
       <!-- <iframe style="width: 100%;height:85vh" src="http://localhost:5173/printTemp"></iframe> -->
    </div>
  </template>
  
  <script lang="ts" setup>
  import { reactive, toRefs, onBeforeMount, onMounted } from 'vue'
//   import temperature from './temperature.vue'
const print = ()=>{
    const iframe: any = document.createElement('iframe')
    iframe.setAttribute('style', 'position:absolute;width:900px;height:800px;border: 0;')
    iframe.setAttribute('src', 'http://localhost:5173/printTemp')
    iframe.style.visibility = 'hidden';
    document.body.appendChild(iframe)
}
onMounted(()=>{
    window.addEventListener('message', (event) => {
      const data = event.data.data
      if (data.code === 'success') {
        console.log(data.test, '父组件接受到了'); // {code: 'success', test: '我是点击iframe页面按钮后过来的数据'} 
        prompt(data.test)
      }
    })
})
  
  </script>
  <style scoped lang='less'>
  </style>